﻿using System;
using System.Text.RegularExpressions;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.Odbc;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class public_html_NewSiteTest_Releaseliste : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string Ord = Request.QueryString["ord"].ToString();
        int spilCounter = 0;
        int anmeldelseCounter = 0;
        int nyhedCounter = 0;
        DateFromMySql NewDate = new DateFromMySql();
        ReviewerMySql SQL = new ReviewerMySql();

        DivResults.InnerHtml = "";

        DivResults.InnerHtml += "<h3>Spil:</h3></b><ul>";

        OdbcDataReader SpilReader = SQL.ExecuteReader("SELECT V2_Spil.*, V2_GloFormat.Navn AS FormatNavn FROM V2_Spil JOIN V2_GloFormat ON V2_GloFormat.id = V2_Spil.Format WHERE V2_Spil.Titel LIKE '%" + Ord + "%';");
        while(SpilReader.Read())
        {
            DivResults.InnerHtml += "<a href=\"" + UI.LinkMake.LinkSpil(SpilReader["id"].ToString(), SpilReader["Titel"].ToString()) + "\">" + SpilReader["Titel"].ToString() + " (" + SpilReader["FormatNavn"].ToString() + ")</a><br />";
            spilCounter++;
        }

        DivResults.InnerHtml += "<br />Resultateter: " + spilCounter.ToString() + "</ul>";

        DivResults.InnerHtml += "<h3>Anmeldelser:</h3></b><ul>";

        OdbcDataReader RewReader = SQL.ExecuteReader("SELECT V2_Anmeldelse.*, V2_GloFormat.Navn AS FormatNavn, V2_Spil.Titel AS SpilTitel FROM V2_Anmeldelse JOIN V2_Spil ON V2_Spil.id = V2_Anmeldelse.SpilID JOIN V2_GloFormat ON V2_GloFormat.id = V2_Spil.Format WHERE V2_Spil.Titel LIKE '%" + Ord + "%';");
        while (RewReader.Read())
        {
            DivResults.InnerHtml += "<a href=\"" + UI.LinkMake.LinkReview(RewReader["id"].ToString(),RewReader["SpilTitel"].ToString()) + "\">" + RewReader["SpilTitel"].ToString() + " (" + RewReader["FormatNavn"].ToString() + ")</a><br />";
            anmeldelseCounter++;
        }

        DivResults.InnerHtml += "<br />Resultateter: " + anmeldelseCounter.ToString() + "</ul>";

        DivResults.InnerHtml += "<h3>Nyheder:</h3></b><ul>";

        OdbcDataReader NewReader = SQL.ExecuteReader("SELECT * FROM V2_Nyhed WHERE Titel LIKE '%" + Ord + "%' OR Header LIKE '%" + Ord + "%' OR Tekst LIKE '%" + Ord + "%'");
        while (NewReader.Read())
        {
            DivResults.InnerHtml += "<a href=\"" + UI.LinkMake.LinkNews(NewReader["id"].ToString(),NewReader["Titel"].ToString()) + "\">" + NewReader["Titel"].ToString() + "</a><br />";
            nyhedCounter++;
        }

        DivResults.InnerHtml += "<br />Resultateter: " + nyhedCounter.ToString() + "</ul>";

        lblOverskrift.Text = "Søge Resultater på '" + Ord + "'";

        this.Title = "Søgning på " + Ord;
    }

}
